
LDFLAGS = -L/usr/local/lib
LDLIBS  = -lwiringPi -lwiringPiDev -lpthread -lm

SOURCE_DIR = source/
OUTPUT_DIR = build/

GCC=g++

tests: robot.o udpreceiver.o logger.o
	$(GCC) -o $(OUTPUT_DIR)tests $(OUTPUT_DIR)robot.o $(OUTPUT_DIR)udpreceiver.o $(OUTPUT_DIR)logger.o \
	tests/drivetest.cpp tests/testUDPReceiver.cpp \
	tests/testLogger.cpp \
	tests/main.cpp $(LDFLAGS) $(LDLIBS)

all: robot.o control.o udpreceiver.o logger.o
	$(GCC) -o $(OUTPUT_DIR)all $(SOURCE_DIR)main.cpp $(OUTPUT_DIR)robot.o $(OUTPUT_DIR)control.o $(OUTPUT_DIR)udpreceiver.o $(OUTPUT_DIR)logger.o $(LDFLAGS) $(LDLIBS)

# the -c option tells it to just compile, otherwise we would need a main()-function
robot.o: 
	$(GCC) -o $(OUTPUT_DIR)$@ -c $(SOURCE_DIR)robot/robot.cpp

control.o:
	$(GCC) -o $(OUTPUT_DIR)$@ -c $(SOURCE_DIR)control/RobControl.cpp

udpreceiver.o: 
	$(GCC) -o $(OUTPUT_DIR)$@ -c $(SOURCE_DIR)udp/UDPReceiver.cpp 

logger.o:
	$(GCC) -o $(OUTPUT_DIR)$@ -c $(SOURCE_DIR)logger/Logger.cpp 
